﻿local SM1 = LibStub("SharedMedia-1.0", true);
local LSM2 = LibStub("LibSharedMedia-2.0", true);
local LSM3 = LibStub("LibSharedMedia-3.0", true);

CWDGMediaPack = CreateFrame("Frame");
CWDGMediaPack.registry = {};

function CWDGMediaPack:Register(mediatype, key, data)
	if SM1 then SM1:Register(mediatype, key, data) end
	if LSM2 then LSM2:Register(mediatype, key, data) end
	if LSM3 then LSM3:Register(mediatype, key, data, 2) end
	table.insert(CWDGMediaPack.registry, { mediatype, key, data });
end

CWDGMediaPack:SetScript("OnEvent", function(self, event)
	if not SM1 then SM1 = LibStub("SharedMedia-1.0", true) end
	if not LSM2 then LSM2 = LibStub("LibSharedMedia-2.0", true) end
	if not LSM3 then LSM3 = LibStub("LibSharedMedia-3.0", true) end
	for _, v in ipairs(CWDGMediaPack.registry) do
		local mediatype, key, data = unpack(v);
		if SM1 then SM1:Register(mediatype, key, data) end
		if LSM2 then LSM2:Register(mediatype, key, data) end
		if LSM3 then LSM3:Register(mediatype, key, data, 2) end
	end
end);
CWDGMediaPack:RegisterEvent("ADDON_LOADED");
